<!--
 * @Description: vue3.0
 * @Author: charles
 * @Date: 2021-11-08 15:28:35
 * @LastEditors: charles
 * @LastEditTime: 2021-11-08 16:07:09
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue3.0</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.1.5/vue.global.js"></script>
</head>
<body>
  <div id="app">
    {{num}}
  </div>
  <script>
    // data
    const ref = Vue.ref;
    const onMounted = Vue.onMounted;

    let app = Vue.createApp({
      // 函数组件 react 
      setup(props){
        let num = ref(1)
        let changeNum = ()=>{
          setInterval(() => {
            num.value = ++num.value;
          }, 1000);
        }
        onMounted(changeNum);

        return {
          num
        }
      }
    });
    app.mount('#app')


  </script>
</body>
</html>
